<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%> 
<script type="text/javascript">
$(function(){
	loadAreaTree("areaTree");
});
//初始化组织机构树
function loadAreaTree(areaTreeId){
	var showPower="${p:isPower('/area/goAreaDetail.shtml',sessionScope.loginAccount)}";
	$.ajax({
    	"dataType": "json",
    	"type": "POST",
    	"url": "<c:url value="/area/areaTreeQuery.shtml"/>",
    	"data": "",
    	async: false,
    	"success": function(data){
    		for(var i=0;i<data.areaList.length;i++){
    			var area=data.areaList[i];
    			var href="javascript;";
    			if(showPower){
        			href="<c:url value="/area/goAreaDetail.shtml"/>?areaId="+area.areaId;
    			}
    			if(area.areaIdParent==null || area.areaId==data.curAreaId){
    				var topUl="<li><a href='"+href+"' target='ajax' rel='areaShowPage'>"+area.areaName+"</a><ul id='"+areaTreeId+"_"+area.areaId+"'></ul></li>";
    				if(area.subCount==0){
    					topUl="<li><a href='"+href+"' target='ajax' rel='areaShowPage'>"+area.areaName+"</a></li>";
    				}
    				$("#"+areaTreeId).append(topUl);
    			}else{
    				var ul="<li><a href='"+href+"' target='ajax' rel='areaShowPage'>"+area.areaName+"</a><ul id='"+areaTreeId+"_"+area.areaId+"'></ul></li>";
    				if(area.subCount==0){
    					ul="<li><a href='"+href+"' target='ajax' rel='areaShowPage'>"+area.areaName+"</a></li>";
    				}
    				$("#"+areaTreeId+"_"+area.areaIdParent).append(ul);
    			}
    		}
    	}
    }); 
}
function clickAreaTree(){
	var json = arguments[0];
	alert(json.checked);
	$(json.items).each(function(i){
		alert("name:"+this.name+"|"+this.value+"|"+this.text);
	});
}
</script>
<div class="pageContent">
	<div class="tabs">
		<div class="tabsHeader">
			<div class="tabsHeaderContent">
				<ul>
					<li><a href="javascript:;"><span>地区管理</span></a></li>
				</ul>
			</div>
		</div>
		<div class="tabsContent">
			<div>
				<div layoutH="160" class="contLeft">
					<ul id="areaTree" class="tree expand">
					
					</ul>
				</div> 
				<div id="areaShowPage" class="unitBox contRight">
				
				</div> 
			</div>
		</div>
	</div>
</div>
